package com.sample.sampleproj;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

public class DetailsActivity extends Activity {
	public void onCreate(Bundle savedInstanceState) {
	       super.onCreate(savedInstanceState);// activity loads its UI from the XML file main.xml. 
	       
	      setContentView(R.layout.details);
	      
	       
	       Bundle extras = getIntent().getExtras();
			//String extraData=extras.getString("map");
	      // extras.get("fillMaps");
	       HashMap<String, String> map =  (HashMap<String, String>) extras.get("map");
	       System.out.println(map.get("Name"));
	     //  Drawable drawable = map.get("Icon");
	       //image.setImageDrawable(drawable);
	        ImageView icon= (ImageView) findViewById(R.id.Icon);
	      icon.setImageDrawable(createDrawableFromURL(map.get("Icon")));
	       //+"Name:"+map.get("Name")+"Location:"+map.get("location")+);
	       //setContentView(txt);
	      TextView Name=(TextView) findViewById(R.id.Name);
	      Name.setText("Name: "+map.get("Name"));
	      TextView Location=(TextView) findViewById(R.id.Location);
	      Location.setText("Location: "+map.get("Location"));
	      TextView Phn=(TextView) findViewById(R.id.Phone);
	      Phn.setText("Phone: "+map.get("Phone"));
	      TextView ws=(TextView) findViewById(R.id.Website);
	      ws.setText("Website: "+map.get("Website"));
	      
	       
	      
	}
	 private Drawable createDrawableFromURL(String urlString) {
	        Drawable image = null;
		try {
		    URL url = new URL(urlString);
		    InputStream is = (InputStream)url.getContent();
		    image = Drawable.createFromStream(is, "src");
		} catch (MalformedURLException e) {
		    // handle URL exception
		    image = null;
		} catch (IOException e) {
		    // handle InputStream exception
		    image = null;
		}
	 
		return image;
	    }
	
}
